package io.xccit.race.service.impl;

import java.util.List;
import io.xccit.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import io.xccit.race.mapper.RaceCompetitionRulesMapper;
import io.xccit.race.domain.RaceCompetitionRules;
import io.xccit.race.service.IRaceCompetitionRulesService;

/**
 * 赛制管理Service业务层处理
 * 
 * @author ywx
 * @date 2025-10-10
 */
@Service
public class RaceCompetitionRulesServiceImpl implements IRaceCompetitionRulesService 
{
    @Autowired
    private RaceCompetitionRulesMapper raceCompetitionRulesMapper;

    /**
     * 查询赛制管理
     * 
     * @param id 赛制管理主键
     * @return 赛制管理
     */
    @Override
    public RaceCompetitionRules selectRaceCompetitionRulesById(Long id)
    {
        return raceCompetitionRulesMapper.selectRaceCompetitionRulesById(id);
    }

    /**
     * 查询赛制管理列表
     * 
     * @param raceCompetitionRules 赛制管理
     * @return 赛制管理
     */
    @Override
    public List<RaceCompetitionRules> selectRaceCompetitionRulesList(RaceCompetitionRules raceCompetitionRules)
    {
        return raceCompetitionRulesMapper.selectRaceCompetitionRulesList(raceCompetitionRules);
    }

    /**
     * 新增赛制管理
     * 
     * @param raceCompetitionRules 赛制管理
     * @return 结果
     */
    @Override
    public int insertRaceCompetitionRules(RaceCompetitionRules raceCompetitionRules)
    {
        raceCompetitionRules.setDelFlag("0");
        raceCompetitionRules.setCreateTime(DateUtils.getNowDate());
        return raceCompetitionRulesMapper.insertRaceCompetitionRules(raceCompetitionRules);
    }

    /**
     * 修改赛制管理
     * 
     * @param raceCompetitionRules 赛制管理
     * @return 结果
     */
    @Override
    public int updateRaceCompetitionRules(RaceCompetitionRules raceCompetitionRules)
    {
        raceCompetitionRules.setUpdateTime(DateUtils.getNowDate());
        return raceCompetitionRulesMapper.updateRaceCompetitionRules(raceCompetitionRules);
    }

    /**
     * 批量删除赛制管理
     * 
     * @param ids 需要删除的赛制管理主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionRulesByIds(Long[] ids)
    {
        return raceCompetitionRulesMapper.deleteRaceCompetitionRulesByIds(ids);
    }

    /**
     * 删除赛制管理信息
     * 
     * @param id 赛制管理主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionRulesById(Long id)
    {
        return raceCompetitionRulesMapper.deleteRaceCompetitionRulesById(id);
    }
    
    /**
     * 根据竞赛ID获取最大参赛人数
     * 
     * @param competitionId 竞赛ID
     * @return 最大参赛人数
     */
    @Override
    public Long getMaxParticipantsByCompetitionId(Long competitionId)
    {
        return raceCompetitionRulesMapper.getMaxParticipantsByCompetitionId(competitionId);
    }
}
